1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gio.Settings; 26 27 private import gio.ActionIF; 28 private import gio.SettingsBackend; 29 private import gio.SettingsSchema; 30 private import gio.c.functions; 31 public import gio.c.types; 32 private import glib.ConstructionException; 33 private import glib.Str; 34 private import glib.Variant; 35 private import glib.c.functions; 36 private import gobject.ObjectG; 37 private import gobject.Signals; 38 private import std.algorithm; 39 40 41 /** 42 * The #GSettings class provides a convenient API for storing and retrieving 43 * application settings. 44 * 45 * Reads and writes can be considered to be non-blocking. Reading 46 * settings with #GSettings is typically extremely fast: on 47 * approximately the same order of magnitude (but slower than) a 48 * #GHashTable lookup. Writing settings is also extremely fast in terms 49 * of time to return to your application, but can be extremely expensive 50 * for other threads and other processes. Many settings backends 51 * (including dconf) have lazy initialisation which means in the common 52 * case of the user using their computer without modifying any settings 53 * a lot of work can be avoided. For dconf, the D-Bus service doesn't 54 * even need to be started in this case. For this reason, you should 55 * only ever modify #GSettings keys in response to explicit user action. 56 * Particular care should be paid to ensure that modifications are not 57 * made during startup -- for example, when setting the initial value 58 * of preferences widgets. The built-in g_settings_bind() functionality 59 * is careful not to write settings in response to notify signals as a 60 * result of modifications that it makes to widgets. 61 * 62 * When creating a GSettings instance, you have to specify a schema 63 * that describes the keys in your settings and their types and default 64 * values, as well as some other information. 65 * 66 * Normally, a schema has a fixed path that determines where the settings 67 * are stored in the conceptual global tree of settings. However, schemas 68 * can also be '[relocatable][gsettings-relocatable]', i.e. not equipped with 69 * a fixed path. This is 70 * useful e.g. when the schema describes an 'account', and you want to be 71 * able to store a arbitrary number of accounts. 72 * 73 * Paths must start with and end with a forward slash character ('/') 74 * and must not contain two sequential slash characters. Paths should 75 * be chosen based on a domain name associated with the program or 76 * library to which the settings belong. Examples of paths are 77 * "/org/gtk/settings/file-chooser/" and "/ca/desrt/dconf-editor/". 78 * Paths should not start with "/apps/", "/desktop/" or "/system/" as 79 * they often did in GConf. 80 * 81 * Unlike other configuration systems (like GConf), GSettings does not 82 * restrict keys to basic types like strings and numbers. GSettings stores 83 * values as #GVariant, and allows any #GVariantType for keys. Key names 84 * are restricted to lowercase characters, numbers and '-'. Furthermore, 85 * the names must begin with a lowercase character, must not end 86 * with a '-', and must not contain consecutive dashes. 87 * 88 * Similar to GConf, the default values in GSettings schemas can be 89 * localized, but the localized values are stored in gettext catalogs 90 * and looked up with the domain that is specified in the 91 * `gettext-domain` attribute of the <schemalist> or <schema> 92 * elements and the category that is specified in the `l10n` attribute of 93 * the <default> element. The string which is translated includes all text in 94 * the <default> element, including any surrounding quotation marks. 95 * 96 * The `l10n` attribute must be set to `messages` or `time`, and sets the 97 * [locale category for 98 * translation](https://www.gnu.org/software/gettext/manual/html_node/Aspects.html#index-locale-categories-1). 99 * The `messages` category should be used by default; use `time` for 100 * translatable date or time formats. A translation comment can be added as an 101 * XML comment immediately above the <default> element — it is recommended to 102 * add these comments to aid translators understand the meaning and 103 * implications of the default value. An optional translation `context` 104 * attribute can be set on the <default> element to disambiguate multiple 105 * defaults which use the same string. 106 * 107 * For example: 108 * |[ 109 * <!-- Translators: A list of words which are not allowed to be typed, in 110 * GVariant serialization syntax. 111 * See: https://developer.gnome.org/glib/stable/gvariant-text.html --> 112 * <default l10n='messages' context='Banned words'>['bad', 'words']</default> 113 * ]| 114 * 115 * Translations of default values must remain syntactically valid serialized 116 * #GVariants (e.g. retaining any surrounding quotation marks) or runtime 117 * errors will occur. 118 * 119 * GSettings uses schemas in a compact binary form that is created 120 * by the [glib-compile-schemas][glib-compile-schemas] 121 * utility. The input is a schema description in an XML format. 122 * 123 * A DTD for the gschema XML format can be found here: 124 * [gschema.dtd](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/gschema.dtd) 125 * 126 * The [glib-compile-schemas][glib-compile-schemas] tool expects schema 127 * files to have the extension `.gschema.xml`. 128 * 129 * At runtime, schemas are identified by their id (as specified in the 130 * id attribute of the <schema> element). The convention for schema 131 * ids is to use a dotted name, similar in style to a D-Bus bus name, 132 * e.g. "org.gnome.SessionManager". In particular, if the settings are 133 * for a specific service that owns a D-Bus bus name, the D-Bus bus name 134 * and schema id should match. For schemas which deal with settings not 135 * associated with one named application, the id should not use 136 * StudlyCaps, e.g. "org.gnome.font-rendering". 137 * 138 * In addition to #GVariant types, keys can have types that have 139 * enumerated types. These can be described by a <choice>, 140 * <enum> or <flags> element, as seen in the 141 * [example][schema-enumerated]. The underlying type of such a key 142 * is string, but you can use g_settings_get_enum(), g_settings_set_enum(), 143 * g_settings_get_flags(), g_settings_set_flags() access the numeric values 144 * corresponding to the string value of enum and flags keys. 145 * 146 * An example for default value: 147 * |[ 148 * <schemalist> 149 * <schema id="org.gtk.Test" path="/org/gtk/Test/" gettext-domain="test"> 150 * 151 * <key name="greeting" type="s"> 152 * <default l10n="messages">"Hello, earthlings"</default> 153 * <summary>A greeting</summary> 154 * <description> 155 * Greeting of the invading martians 156 * </description> 157 * </key> 158 * 159 * <key name="box" type="(ii)"> 160 * <default>(20,30)</default> 161 * </key> 162 * 163 * <key name="empty-string" type="s"> 164 * <default>""</default> 165 * <summary>Empty strings have to be provided in GVariant form</summary> 166 * </key> 167 * 168 * </schema> 169 * </schemalist> 170 * ]| 171 * 172 * An example for ranges, choices and enumerated types: 173 * |[ 174 * <schemalist> 175 * 176 * <enum id="org.gtk.Test.myenum"> 177 * <value nick="first" value="1"/> 178 * <value nick="second" value="2"/> 179 * </enum> 180 * 181 * <flags id="org.gtk.Test.myflags"> 182 * <value nick="flag1" value="1"/> 183 * <value nick="flag2" value="2"/> 184 * <value nick="flag3" value="4"/> 185 * </flags> 186 * 187 * <schema id="org.gtk.Test"> 188 * 189 * <key name="key-with-range" type="i"> 190 * <range min="1" max="100"/> 191 * <default>10</default> 192 * </key> 193 * 194 * <key name="key-with-choices" type="s"> 195 * <choices> 196 * <choice value='Elisabeth'/> 197 * <choice value='Annabeth'/> 198 * <choice value='Joe'/> 199 * </choices> 200 * <aliases> 201 * <alias value='Anna' target='Annabeth'/> 202 * <alias value='Beth' target='Elisabeth'/> 203 * </aliases> 204 * <default>'Joe'</default> 205 * </key> 206 * 207 * <key name='enumerated-key' enum='org.gtk.Test.myenum'> 208 * <default>'first'</default> 209 * </key> 210 * 211 * <key name='flags-key' flags='org.gtk.Test.myflags'> 212 * <default>["flag1","flag2"]</default> 213 * </key> 214 * </schema> 215 * </schemalist> 216 * ]| 217 * 218 * ## Vendor overrides 219 * 220 * Default values are defined in the schemas that get installed by 221 * an application. Sometimes, it is necessary for a vendor or distributor 222 * to adjust these defaults. Since patching the XML source for the schema 223 * is inconvenient and error-prone, 224 * [glib-compile-schemas][glib-compile-schemas] reads so-called vendor 225 * override' files. These are keyfiles in the same directory as the XML 226 * schema sources which can override default values. The schema id serves 227 * as the group name in the key file, and the values are expected in 228 * serialized GVariant form, as in the following example: 229 * |[ 230 * [org.gtk.Example] 231 * key1='string' 232 * key2=1.5 233 * ]| 234 * 235 * glib-compile-schemas expects schema files to have the extension 236 * `.gschema.override`. 237 * 238 * ## Binding 239 * 240 * A very convenient feature of GSettings lets you bind #GObject properties 241 * directly to settings, using g_settings_bind(). Once a GObject property 242 * has been bound to a setting, changes on either side are automatically 243 * propagated to the other side. GSettings handles details like mapping 244 * between GObject and GVariant types, and preventing infinite cycles. 245 * 246 * This makes it very easy to hook up a preferences dialog to the 247 * underlying settings. To make this even more convenient, GSettings 248 * looks for a boolean property with the name "sensitivity" and 249 * automatically binds it to the writability of the bound setting. 250 * If this 'magic' gets in the way, it can be suppressed with the 251 * %G_SETTINGS_BIND_NO_SENSITIVITY flag. 252 * 253 * ## Relocatable schemas # {#gsettings-relocatable} 254 * 255 * A relocatable schema is one with no `path` attribute specified on its 256 * <schema> element. By using g_settings_new_with_path(), a #GSettings object 257 * can be instantiated for a relocatable schema, assigning a path to the 258 * instance. Paths passed to g_settings_new_with_path() will typically be 259 * constructed dynamically from a constant prefix plus some form of instance 260 * identifier; but they must still be valid GSettings paths. Paths could also 261 * be constant and used with a globally installed schema originating from a 262 * dependency library. 263 * 264 * For example, a relocatable schema could be used to store geometry information 265 * for different windows in an application. If the schema ID was 266 * `org.foo.MyApp.Window`, it could be instantiated for paths 267 * `/org/foo/MyApp/main/`, `/org/foo/MyApp/document-1/`, 268 * `/org/foo/MyApp/document-2/`, etc. If any of the paths are well-known 269 * they can be specified as <child> elements in the parent schema, e.g.: 270 * |[ 271 * <schema id="org.foo.MyApp" path="/org/foo/MyApp/"> 272 * <child name="main" schema="org.foo.MyApp.Window"/> 273 * </schema> 274 * ]| 275 * 276 * ## Build system integration # {#gsettings-build-system} 277 * 278 * GSettings comes with autotools integration to simplify compiling and 279 * installing schemas. To add GSettings support to an application, add the 280 * following to your `configure.ac`: 281 * |[ 282 * GLIB_GSETTINGS 283 * ]| 284 * 285 * In the appropriate `Makefile.am`, use the following snippet to compile and 286 * install the named schema: 287 * |[ 288 * gsettings_SCHEMAS = org.foo.MyApp.gschema.xml 289 * EXTRA_DIST = $(gsettings_SCHEMAS) 290 * 291 * @GSETTINGS_RULES@ 292 * ]| 293 * 294 * No changes are needed to the build system to mark a schema XML file for 295 * translation. Assuming it sets the `gettext-domain` attribute, a schema may 296 * be marked for translation by adding it to `POTFILES.in`, assuming gettext 297 * 0.19 is in use (the preferred method for translation): 298 * |[ 299 * data/org.foo.MyApp.gschema.xml 300 * ]| 301 * 302 * Alternatively, if intltool 0.50.1 is in use: 303 * |[ 304 * [type: gettext/gsettings]data/org.foo.MyApp.gschema.xml 305 * ]| 306 * 307 * GSettings will use gettext to look up translations for the <summary> and 308 * <description> elements, and also any <default> elements which have a `l10n` 309 * attribute set. Translations must not be included in the `.gschema.xml` file 310 * by the build system, for example by using intltool XML rules with a 311 * `.gschema.xml.in` template. 312 * 313 * If an enumerated type defined in a C header file is to be used in a GSettings 314 * schema, it can either be defined manually using an <enum> element in the 315 * schema XML, or it can be extracted automatically from the C header. This 316 * approach is preferred, as it ensures the two representations are always 317 * synchronised. To do so, add the following to the relevant `Makefile.am`: 318 * |[ 319 * gsettings_ENUM_NAMESPACE = org.foo.MyApp 320 * gsettings_ENUM_FILES = my-app-enums.h my-app-misc.h 321 * ]| 322 * 323 * `gsettings_ENUM_NAMESPACE` specifies the schema namespace for the enum files, 324 * which are specified in `gsettings_ENUM_FILES`. This will generate a 325 * `org.foo.MyApp.enums.xml` file containing the extracted enums, which will be 326 * automatically included in the schema compilation, install and uninstall 327 * rules. It should not be committed to version control or included in 328 * `EXTRA_DIST`. 329 */ 330 public class Settings : ObjectG 331 { 332 /** the main Gtk struct */ 333 protected GSettings* gSettings; 334 335 /** Get the main Gtk struct */ 336 public GSettings* getSettingsStruct(bool transferOwnership = false) 337 { 338 if (transferOwnership) 339 ownedRef = false; 340 return gSettings; 341 } 342 343 /** the main Gtk struct as a void* */ 344 protected override void* getStruct() 345 { 346 return cast(void*)gSettings; 347 } 348 349 /** 350 * Sets our main struct and passes it to the parent class. 351 */ 352 public this (GSettings* gSettings, bool ownedRef = false) 353 { 354 this.gSettings = gSettings; 355 super(cast(GObject*)gSettings, ownedRef); 356 } 357 358 359 /** */ 360 public static GType getType() 361 { 362 return g_settings_get_type(); 363 } 364 365 /** 366 * Creates a new #GSettings object with the schema specified by 367 * @schema_id. 368 * 369 * It is an error for the schema to not exist: schemas are an 370 * essential part of a program, as they provide type information. 371 * If schemas need to be dynamically loaded (for example, from an 372 * optional runtime dependency), g_settings_schema_source_lookup() 373 * can be used to test for their existence before loading them. 374 * 375 * Signals on the newly created #GSettings object will be dispatched 376 * via the thread-default #GMainContext in effect at the time of the 377 * call to g_settings_new(). The new #GSettings will hold a reference 378 * on the context. See g_main_context_push_thread_default(). 379 * 380 * Params: 381 * schemaId = the id of the schema 382 * 383 * Returns: a new #GSettings object 384 * 385 * Since: 2.26 386 * 387 * Throws: ConstructionException GTK+ fails to create the object. 388 */ 389 public this(string schemaId) 390 { 391 auto __p = g_settings_new(Str.toStringz(schemaId)); 392 393 if(__p is null) 394 { 395 throw new ConstructionException("null returned by new"); 396 } 397 398 this(cast(GSettings*) __p, true); 399 } 400 401 /** 402 * Creates a new #GSettings object with a given schema, backend and 403 * path. 404 * 405 * It should be extremely rare that you ever want to use this function. 406 * It is made available for advanced use-cases (such as plugin systems 407 * that want to provide access to schemas loaded from custom locations, 408 * etc). 409 * 410 * At the most basic level, a #GSettings object is a pure composition of 411 * 4 things: a #GSettingsSchema, a #GSettingsBackend, a path within that 412 * backend, and a #GMainContext to which signals are dispatched. 413 * 414 * This constructor therefore gives you full control over constructing 415 * #GSettings instances. The first 3 parameters are given directly as 416 * @schema, @backend and @path, and the main context is taken from the 417 * thread-default (as per g_settings_new()). 418 * 419 * If @backend is %NULL then the default backend is used. 420 * 421 * If @path is %NULL then the path from the schema is used. It is an 422 * error if @path is %NULL and the schema has no path of its own or if 423 * @path is non-%NULL and not equal to the path that the schema does 424 * have. 425 * 426 * Params: 427 * schema = a #GSettingsSchema 428 * backend = a #GSettingsBackend 429 * path = the path to use 430 * 431 * Returns: a new #GSettings object 432 * 433 * Since: 2.32 434 * 435 * Throws: ConstructionException GTK+ fails to create the object. 436 */ 437 public this(SettingsSchema schema, SettingsBackend backend, string path) 438 { 439 auto __p = g_settings_new_full((schema is null) ? null : schema.getSettingsSchemaStruct(), (backend is null) ? null : backend.getSettingsBackendStruct(), Str.toStringz(path)); 440 441 if(__p is null) 442 { 443 throw new ConstructionException("null returned by new_full"); 444 } 445 446 this(cast(GSettings*) __p, true); 447 } 448 449 /** 450 * Creates a new #GSettings object with the schema specified by 451 * @schema_id and a given #GSettingsBackend. 452 * 453 * Creating a #GSettings object with a different backend allows accessing 454 * settings from a database other than the usual one. For example, it may make 455 * sense to pass a backend corresponding to the "defaults" settings database on 456 * the system to get a settings object that modifies the system default 457 * settings instead of the settings for this user. 458 * 459 * Params: 460 * schemaId = the id of the schema 461 * backend = the #GSettingsBackend to use 462 * 463 * Returns: a new #GSettings object 464 * 465 * Since: 2.26 466 * 467 * Throws: ConstructionException GTK+ fails to create the object. 468 */ 469 public this(string schemaId, SettingsBackend backend) 470 { 471 auto __p = g_settings_new_with_backend(Str.toStringz(schemaId), (backend is null) ? null : backend.getSettingsBackendStruct()); 472 473 if(__p is null) 474 { 475 throw new ConstructionException("null returned by new_with_backend"); 476 } 477 478 this(cast(GSettings*) __p, true); 479 } 480 481 /** 482 * Creates a new #GSettings object with the schema specified by 483 * @schema_id and a given #GSettingsBackend and path. 484 * 485 * This is a mix of g_settings_new_with_backend() and 486 * g_settings_new_with_path(). 487 * 488 * Params: 489 * schemaId = the id of the schema 490 * backend = the #GSettingsBackend to use 491 * path = the path to use 492 * 493 * Returns: a new #GSettings object 494 * 495 * Since: 2.26 496 * 497 * Throws: ConstructionException GTK+ fails to create the object. 498 */ 499 public this(string schemaId, SettingsBackend backend, string path) 500 { 501 auto __p = g_settings_new_with_backend_and_path(Str.toStringz(schemaId), (backend is null) ? null : backend.getSettingsBackendStruct(), Str.toStringz(path)); 502 503 if(__p is null) 504 { 505 throw new ConstructionException("null returned by new_with_backend_and_path"); 506 } 507 508 this(cast(GSettings*) __p, true); 509 } 510 511 /** 512 * Creates a new #GSettings object with the relocatable schema specified 513 * by @schema_id and a given path. 514 * 515 * You only need to do this if you want to directly create a settings 516 * object with a schema that doesn't have a specified path of its own. 517 * That's quite rare. 518 * 519 * It is a programmer error to call this function for a schema that 520 * has an explicitly specified path. 521 * 522 * It is a programmer error if @path is not a valid path. A valid path 523 * begins and ends with '/' and does not contain two consecutive '/' 524 * characters. 525 * 526 * Params: 527 * schemaId = the id of the schema 528 * path = the path to use 529 * 530 * Returns: a new #GSettings object 531 * 532 * Since: 2.26 533 * 534 * Throws: ConstructionException GTK+ fails to create the object. 535 */ 536 public this(string schemaId, string path) 537 { 538 auto __p = g_settings_new_with_path(Str.toStringz(schemaId), Str.toStringz(path)); 539 540 if(__p is null) 541 { 542 throw new ConstructionException("null returned by new_with_path"); 543 } 544 545 this(cast(GSettings*) __p, true); 546 } 547 548 /** 549 * Deprecated. 550 * 551 * Deprecated: Use g_settings_schema_source_list_schemas() instead 552 * 553 * Returns: a list of 554 * relocatable #GSettings schemas that are available, in no defined order. 555 * The list must not be modified or freed. 556 * 557 * Since: 2.28 558 */ 559 public static string[] listRelocatableSchemas() 560 { 561 return Str.toStringArray(g_settings_list_relocatable_schemas()); 562 } 563 564 /** 565 * Deprecated. 566 * 567 * Deprecated: Use g_settings_schema_source_list_schemas() instead. 568 * If you used g_settings_list_schemas() to check for the presence of 569 * a particular schema, use g_settings_schema_source_lookup() instead 570 * of your whole loop. 571 * 572 * Returns: a list of 573 * #GSettings schemas that are available, in no defined order. The list 574 * must not be modified or freed. 575 * 576 * Since: 2.26 577 */ 578 public static string[] listSchemas() 579 { 580 return Str.toStringArray(g_settings_list_schemas()); 581 } 582 583 /** 584 * Ensures that all pending operations are complete for the default backend. 585 * 586 * Writes made to a #GSettings are handled asynchronously. For this 587 * reason, it is very unlikely that the changes have it to disk by the 588 * time g_settings_set() returns. 589 * 590 * This call will block until all of the writes have made it to the 591 * backend. Since the mainloop is not running, no change notifications 592 * will be dispatched during this call (but some may be queued by the 593 * time the call is done). 594 */ 595 public static void sync() 596 { 597 g_settings_sync(); 598 } 599 600 /** 601 * Removes an existing binding for @property on @object. 602 * 603 * Note that bindings are automatically removed when the 604 * object is finalized, so it is rarely necessary to call this 605 * function. 606 * 607 * Params: 608 * object = the object 609 * property = the property whose binding is removed 610 * 611 * Since: 2.26 612 */ 613 public static void unbind(ObjectG object, string property) 614 { 615 g_settings_unbind((object is null) ? null : object.getObjectGStruct(), Str.toStringz(property)); 616 } 617 618 /** 619 * Applies any changes that have been made to the settings. This 620 * function does nothing unless @settings is in 'delay-apply' mode; 621 * see g_settings_delay(). In the normal case settings are always 622 * applied immediately. 623 */ 624 public void apply() 625 { 626 g_settings_apply(gSettings); 627 } 628 629 /** 630 * Create a binding between the @key in the @settings object 631 * and the property @property of @object. 632 * 633 * The binding uses the default GIO mapping functions to map 634 * between the settings and property values. These functions 635 * handle booleans, numeric types and string types in a 636 * straightforward way. Use g_settings_bind_with_mapping() if 637 * you need a custom mapping, or map between types that are not 638 * supported by the default mapping functions. 639 * 640 * Unless the @flags include %G_SETTINGS_BIND_NO_SENSITIVITY, this 641 * function also establishes a binding between the writability of 642 * @key and the "sensitive" property of @object (if @object has 643 * a boolean property by that name). See g_settings_bind_writable() 644 * for more details about writable bindings. 645 * 646 * Note that the lifecycle of the binding is tied to @object, 647 * and that you can have only one binding per object property. 648 * If you bind the same property twice on the same object, the second 649 * binding overrides the first one. 650 * 651 * Params: 652 * key = the key to bind 653 * object = a #GObject 654 * property = the name of the property to bind 655 * flags = flags for the binding 656 * 657 * Since: 2.26 658 */ 659 public void bind(string key, ObjectG object, string property, GSettingsBindFlags flags) 660 { 661 g_settings_bind(gSettings, Str.toStringz(key), (object is null) ? null : object.getObjectGStruct(), Str.toStringz(property), flags); 662 } 663 664 /** 665 * Create a binding between the @key in the @settings object 666 * and the property @property of @object. 667 * 668 * The binding uses the provided mapping functions to map between 669 * settings and property values. 670 * 671 * Note that the lifecycle of the binding is tied to @object, 672 * and that you can have only one binding per object property. 673 * If you bind the same property twice on the same object, the second 674 * binding overrides the first one. 675 * 676 * Params: 677 * key = the key to bind 678 * object = a #GObject 679 * property = the name of the property to bind 680 * flags = flags for the binding 681 * getMapping = a function that gets called to convert values 682 * from @settings to @object, or %NULL to use the default GIO mapping 683 * setMapping = a function that gets called to convert values 684 * from @object to @settings, or %NULL to use the default GIO mapping 685 * userData = data that gets passed to @get_mapping and @set_mapping 686 * destroy = #GDestroyNotify function for @user_data 687 * 688 * Since: 2.26 689 */ 690 public void bindWithMapping(string key, ObjectG object, string property, GSettingsBindFlags flags, GSettingsBindGetMapping getMapping, GSettingsBindSetMapping setMapping, void* userData, GDestroyNotify destroy) 691 { 692 g_settings_bind_with_mapping(gSettings, Str.toStringz(key), (object is null) ? null : object.getObjectGStruct(), Str.toStringz(property), flags, getMapping, setMapping, userData, destroy); 693 } 694 695 /** 696 * Create a binding between the writability of @key in the 697 * @settings object and the property @property of @object. 698 * The property must be boolean; "sensitive" or "visible" 699 * properties of widgets are the most likely candidates. 700 * 701 * Writable bindings are always uni-directional; changes of the 702 * writability of the setting will be propagated to the object 703 * property, not the other way. 704 * 705 * When the @inverted argument is %TRUE, the binding inverts the 706 * value as it passes from the setting to the object, i.e. @property 707 * will be set to %TRUE if the key is not writable. 708 * 709 * Note that the lifecycle of the binding is tied to @object, 710 * and that you can have only one binding per object property. 711 * If you bind the same property twice on the same object, the second 712 * binding overrides the first one. 713 * 714 * Params: 715 * key = the key to bind 716 * object = a #GObject 717 * property = the name of a boolean property to bind 718 * inverted = whether to 'invert' the value 719 * 720 * Since: 2.26 721 */ 722 public void bindWritable(string key, ObjectG object, string property, bool inverted) 723 { 724 g_settings_bind_writable(gSettings, Str.toStringz(key), (object is null) ? null : object.getObjectGStruct(), Str.toStringz(property), inverted); 725 } 726 727 /** 728 * Creates a #GAction corresponding to a given #GSettings key. 729 * 730 * The action has the same name as the key. 731 * 732 * The value of the key becomes the state of the action and the action 733 * is enabled when the key is writable. Changing the state of the 734 * action results in the key being written to. Changes to the value or 735 * writability of the key cause appropriate change notifications to be 736 * emitted for the action. 737 * 738 * For boolean-valued keys, action activations take no parameter and 739 * result in the toggling of the value. For all other types, 740 * activations take the new value for the key (which must have the 741 * correct type). 742 * 743 * Params: 744 * key = the name of a key in @settings 745 * 746 * Returns: a new #GAction 747 * 748 * Since: 2.32 749 */ 750 public ActionIF createAction(string key) 751 { 752 auto __p = g_settings_create_action(gSettings, Str.toStringz(key)); 753 754 if(__p is null) 755 { 756 return null; 757 } 758 759 return ObjectG.getDObject!(ActionIF)(cast(GAction*) __p, true); 760 } 761 762 /** 763 * Changes the #GSettings object into 'delay-apply' mode. In this 764 * mode, changes to @settings are not immediately propagated to the 765 * backend, but kept locally until g_settings_apply() is called. 766 * 767 * Since: 2.26 768 */ 769 public void delay() 770 { 771 g_settings_delay(gSettings); 772 } 773 774 /** 775 * Gets the value that is stored at @key in @settings. 776 * 777 * A convenience variant of g_settings_get() for booleans. 778 * 779 * It is a programmer error to give a @key that isn't specified as 780 * having a boolean type in the schema for @settings. 781 * 782 * Params: 783 * key = the key to get the value for 784 * 785 * Returns: a boolean 786 * 787 * Since: 2.26 788 */ 789 public bool getBoolean(string key) 790 { 791 return g_settings_get_boolean(gSettings, Str.toStringz(key)) != 0; 792 } 793 794 /** 795 * Creates a child settings object which has a base path of 796 * `base-path/@name`, where `base-path` is the base path of 797 * @settings. 798 * 799 * The schema for the child settings object must have been declared 800 * in the schema of @settings using a `<child>` element. 801 * 802 * The created child settings object will inherit the #GSettings:delay-apply 803 * mode from @settings. 804 * 805 * Params: 806 * name = the name of the child schema 807 * 808 * Returns: a 'child' settings object 809 * 810 * Since: 2.26 811 */ 812 public Settings getChild(string name) 813 { 814 auto __p = g_settings_get_child(gSettings, Str.toStringz(name)); 815 816 if(__p is null) 817 { 818 return null; 819 } 820 821 return ObjectG.getDObject!(Settings)(cast(GSettings*) __p, true); 822 } 823 824 /** 825 * Gets the "default value" of a key. 826 * 827 * This is the value that would be read if g_settings_reset() were to be 828 * called on the key. 829 * 830 * Note that this may be a different value than returned by 831 * g_settings_schema_key_get_default_value() if the system administrator 832 * has provided a default value. 833 * 834 * Comparing the return values of g_settings_get_default_value() and 835 * g_settings_get_value() is not sufficient for determining if a value 836 * has been set because the user may have explicitly set the value to 837 * something that happens to be equal to the default. The difference 838 * here is that if the default changes in the future, the user's key 839 * will still be set. 840 * 841 * This function may be useful for adding an indication to a UI of what 842 * the default value was before the user set it. 843 * 844 * It is a programmer error to give a @key that isn't contained in the 845 * schema for @settings. 846 * 847 * Params: 848 * key = the key to get the default value for 849 * 850 * Returns: the default value 851 * 852 * Since: 2.40 853 */ 854 public Variant getDefaultValue(string key) 855 { 856 auto __p = g_settings_get_default_value(gSettings, Str.toStringz(key)); 857 858 if(__p is null) 859 { 860 return null; 861 } 862 863 return new Variant(cast(GVariant*) __p, true); 864 } 865 866 /** 867 * Gets the value that is stored at @key in @settings. 868 * 869 * A convenience variant of g_settings_get() for doubles. 870 * 871 * It is a programmer error to give a @key that isn't specified as 872 * having a 'double' type in the schema for @settings. 873 * 874 * Params: 875 * key = the key to get the value for 876 * 877 * Returns: a double 878 * 879 * Since: 2.26 880 */ 881 public double getDouble(string key) 882 { 883 return g_settings_get_double(gSettings, Str.toStringz(key)); 884 } 885 886 /** 887 * Gets the value that is stored in @settings for @key and converts it 888 * to the enum value that it represents. 889 * 890 * In order to use this function the type of the value must be a string 891 * and it must be marked in the schema file as an enumerated type. 892 * 893 * It is a programmer error to give a @key that isn't contained in the 894 * schema for @settings or is not marked as an enumerated type. 895 * 896 * If the value stored in the configuration database is not a valid 897 * value for the enumerated type then this function will return the 898 * default value. 899 * 900 * Params: 901 * key = the key to get the value for 902 * 903 * Returns: the enum value 904 * 905 * Since: 2.26 906 */ 907 public int getEnum(string key) 908 { 909 return g_settings_get_enum(gSettings, Str.toStringz(key)); 910 } 911 912 /** 913 * Gets the value that is stored in @settings for @key and converts it 914 * to the flags value that it represents. 915 * 916 * In order to use this function the type of the value must be an array 917 * of strings and it must be marked in the schema file as a flags type. 918 * 919 * It is a programmer error to give a @key that isn't contained in the 920 * schema for @settings or is not marked as a flags type. 921 * 922 * If the value stored in the configuration database is not a valid 923 * value for the flags type then this function will return the default 924 * value. 925 * 926 * Params: 927 * key = the key to get the value for 928 * 929 * Returns: the flags value 930 * 931 * Since: 2.26 932 */ 933 public uint getFlags(string key) 934 { 935 return g_settings_get_flags(gSettings, Str.toStringz(key)); 936 } 937 938 /** 939 * Returns whether the #GSettings object has any unapplied 940 * changes. This can only be the case if it is in 'delayed-apply' mode. 941 * 942 * Returns: %TRUE if @settings has unapplied changes 943 * 944 * Since: 2.26 945 */ 946 public bool getHasUnapplied() 947 { 948 return g_settings_get_has_unapplied(gSettings) != 0; 949 } 950 951 /** 952 * Gets the value that is stored at @key in @settings. 953 * 954 * A convenience variant of g_settings_get() for 32-bit integers. 955 * 956 * It is a programmer error to give a @key that isn't specified as 957 * having a int32 type in the schema for @settings. 958 * 959 * Params: 960 * key = the key to get the value for 961 * 962 * Returns: an integer 963 * 964 * Since: 2.26 965 */ 966 public int getInt(string key) 967 { 968 return g_settings_get_int(gSettings, Str.toStringz(key)); 969 } 970 971 /** 972 * Gets the value that is stored at @key in @settings. 973 * 974 * A convenience variant of g_settings_get() for 64-bit integers. 975 * 976 * It is a programmer error to give a @key that isn't specified as 977 * having a int64 type in the schema for @settings. 978 * 979 * Params: 980 * key = the key to get the value for 981 * 982 * Returns: a 64-bit integer 983 * 984 * Since: 2.50 985 */ 986 public long getInt64(string key) 987 { 988 return g_settings_get_int64(gSettings, Str.toStringz(key)); 989 } 990 991 /** 992 * Gets the value that is stored at @key in @settings, subject to 993 * application-level validation/mapping. 994 * 995 * You should use this function when the application needs to perform 996 * some processing on the value of the key (for example, parsing). The 997 * @mapping function performs that processing. If the function 998 * indicates that the processing was unsuccessful (due to a parse error, 999 * for example) then the mapping is tried again with another value. 1000 * 1001 * This allows a robust 'fall back to defaults' behaviour to be 1002 * implemented somewhat automatically. 1003 * 1004 * The first value that is tried is the user's setting for the key. If 1005 * the mapping function fails to map this value, other values may be 1006 * tried in an unspecified order (system or site defaults, translated 1007 * schema default values, untranslated schema default values, etc). 1008 * 1009 * If the mapping function fails for all possible values, one additional 1010 * attempt is made: the mapping function is called with a %NULL value. 1011 * If the mapping function still indicates failure at this point then 1012 * the application will be aborted. 1013 * 1014 * The result parameter for the @mapping function is pointed to a 1015 * #gpointer which is initially set to %NULL. The same pointer is given 1016 * to each invocation of @mapping. The final value of that #gpointer is 1017 * what is returned by this function. %NULL is valid; it is returned 1018 * just as any other value would be. 1019 * 1020 * Params: 1021 * key = the key to get the value for 1022 * mapping = the function to map the value in the 1023 * settings database to the value used by the application 1024 * userData = user data for @mapping 1025 * 1026 * Returns: the result, which may be %NULL 1027 */ 1028 public void* getMapped(string key, GSettingsGetMapping mapping, void* userData) 1029 { 1030 return g_settings_get_mapped(gSettings, Str.toStringz(key), mapping, userData); 1031 } 1032 1033 /** 1034 * Queries the range of a key. 1035 * 1036 * Deprecated: Use g_settings_schema_key_get_range() instead. 1037 * 1038 * Params: 1039 * key = the key to query the range of 1040 * 1041 * Since: 2.28 1042 */ 1043 public Variant getRange(string key) 1044 { 1045 auto __p = g_settings_get_range(gSettings, Str.toStringz(key)); 1046 1047 if(__p is null) 1048 { 1049 return null; 1050 } 1051 1052 return new Variant(cast(GVariant*) __p, true); 1053 } 1054 1055 /** 1056 * Gets the value that is stored at @key in @settings. 1057 * 1058 * A convenience variant of g_settings_get() for strings. 1059 * 1060 * It is a programmer error to give a @key that isn't specified as 1061 * having a string type in the schema for @settings. 1062 * 1063 * Params: 1064 * key = the key to get the value for 1065 * 1066 * Returns: a newly-allocated string 1067 * 1068 * Since: 2.26 1069 */ 1070 public string getString(string key) 1071 { 1072 auto retStr = g_settings_get_string(gSettings, Str.toStringz(key)); 1073 1074 scope(exit) Str.freeString(retStr); 1075 return Str.toString(retStr); 1076 } 1077 1078 /** 1079 * A convenience variant of g_settings_get() for string arrays. 1080 * 1081 * It is a programmer error to give a @key that isn't specified as 1082 * having an array of strings type in the schema for @settings. 1083 * 1084 * Params: 1085 * key = the key to get the value for 1086 * 1087 * Returns: a 1088 * newly-allocated, %NULL-terminated array of strings, the value that 1089 * is stored at @key in @settings. 1090 * 1091 * Since: 2.26 1092 */ 1093 public string[] getStrv(string key) 1094 { 1095 auto retStr = g_settings_get_strv(gSettings, Str.toStringz(key)); 1096 1097 scope(exit) Str.freeStringArray(retStr); 1098 return Str.toStringArray(retStr); 1099 } 1100 1101 /** 1102 * Gets the value that is stored at @key in @settings. 1103 * 1104 * A convenience variant of g_settings_get() for 32-bit unsigned 1105 * integers. 1106 * 1107 * It is a programmer error to give a @key that isn't specified as 1108 * having a uint32 type in the schema for @settings. 1109 * 1110 * Params: 1111 * key = the key to get the value for 1112 * 1113 * Returns: an unsigned integer 1114 * 1115 * Since: 2.30 1116 */ 1117 public uint getUint(string key) 1118 { 1119 return g_settings_get_uint(gSettings, Str.toStringz(key)); 1120 } 1121 1122 /** 1123 * Gets the value that is stored at @key in @settings. 1124 * 1125 * A convenience variant of g_settings_get() for 64-bit unsigned 1126 * integers. 1127 * 1128 * It is a programmer error to give a @key that isn't specified as 1129 * having a uint64 type in the schema for @settings. 1130 * 1131 * Params: 1132 * key = the key to get the value for 1133 * 1134 * Returns: a 64-bit unsigned integer 1135 * 1136 * Since: 2.50 1137 */ 1138 public ulong getUint64(string key) 1139 { 1140 return g_settings_get_uint64(gSettings, Str.toStringz(key)); 1141 } 1142 1143 /** 1144 * Checks the "user value" of a key, if there is one. 1145 * 1146 * The user value of a key is the last value that was set by the user. 1147 * 1148 * After calling g_settings_reset() this function should always return 1149 * %NULL (assuming something is not wrong with the system 1150 * configuration). 1151 * 1152 * It is possible that g_settings_get_value() will return a different 1153 * value than this function. This can happen in the case that the user 1154 * set a value for a key that was subsequently locked down by the system 1155 * administrator -- this function will return the user's old value. 1156 * 1157 * This function may be useful for adding a "reset" option to a UI or 1158 * for providing indication that a particular value has been changed. 1159 * 1160 * It is a programmer error to give a @key that isn't contained in the 1161 * schema for @settings. 1162 * 1163 * Params: 1164 * key = the key to get the user value for 1165 * 1166 * Returns: the user's value, if set 1167 * 1168 * Since: 2.40 1169 */ 1170 public Variant getUserValue(string key) 1171 { 1172 auto __p = g_settings_get_user_value(gSettings, Str.toStringz(key)); 1173 1174 if(__p is null) 1175 { 1176 return null; 1177 } 1178 1179 return new Variant(cast(GVariant*) __p, true); 1180 } 1181 1182 /** 1183 * Gets the value that is stored in @settings for @key. 1184 * 1185 * It is a programmer error to give a @key that isn't contained in the 1186 * schema for @settings. 1187 * 1188 * Params: 1189 * key = the key to get the value for 1190 * 1191 * Returns: a new #GVariant 1192 * 1193 * Since: 2.26 1194 */ 1195 public Variant getValue(string key) 1196 { 1197 auto __p = g_settings_get_value(gSettings, Str.toStringz(key)); 1198 1199 if(__p is null) 1200 { 1201 return null; 1202 } 1203 1204 return new Variant(cast(GVariant*) __p, true); 1205 } 1206 1207 /** 1208 * Finds out if a key can be written or not 1209 * 1210 * Params: 1211 * name = the name of a key 1212 * 1213 * Returns: %TRUE if the key @name is writable 1214 * 1215 * Since: 2.26 1216 */ 1217 public bool isWritable(string name) 1218 { 1219 return g_settings_is_writable(gSettings, Str.toStringz(name)) != 0; 1220 } 1221 1222 /** 1223 * Gets the list of children on @settings. 1224 * 1225 * The list is exactly the list of strings for which it is not an error 1226 * to call g_settings_get_child(). 1227 * 1228 * There is little reason to call this function from "normal" code, since 1229 * you should already know what children are in your schema. This function 1230 * may still be useful there for introspection reasons, however. 1231 * 1232 * You should free the return value with g_strfreev() when you are done 1233 * with it. 1234 * 1235 * Returns: a list of the children 1236 * on @settings, in no defined order 1237 */ 1238 public string[] listChildren() 1239 { 1240 auto retStr = g_settings_list_children(gSettings); 1241 1242 scope(exit) Str.freeStringArray(retStr); 1243 return Str.toStringArray(retStr); 1244 } 1245 1246 /** 1247 * Introspects the list of keys on @settings. 1248 * 1249 * You should probably not be calling this function from "normal" code 1250 * (since you should already know what keys are in your schema). This 1251 * function is intended for introspection reasons. 1252 * 1253 * You should free the return value with g_strfreev() when you are done 1254 * with it. 1255 * 1256 * Deprecated: Use g_settings_schema_list_keys() instead. 1257 * 1258 * Returns: a list 1259 * of the keys on @settings, in no defined order 1260 */ 1261 public string[] listKeys() 1262 { 1263 auto retStr = g_settings_list_keys(gSettings); 1264 1265 scope(exit) Str.freeStringArray(retStr); 1266 return Str.toStringArray(retStr); 1267 } 1268 1269 /** 1270 * Checks if the given @value is of the correct type and within the 1271 * permitted range for @key. 1272 * 1273 * Deprecated: Use g_settings_schema_key_range_check() instead. 1274 * 1275 * Params: 1276 * key = the key to check 1277 * value = the value to check 1278 * 1279 * Returns: %TRUE if @value is valid for @key 1280 * 1281 * Since: 2.28 1282 */ 1283 public bool rangeCheck(string key, Variant value) 1284 { 1285 return g_settings_range_check(gSettings, Str.toStringz(key), (value is null) ? null : value.getVariantStruct()) != 0; 1286 } 1287 1288 /** 1289 * Resets @key to its default value. 1290 * 1291 * This call resets the key, as much as possible, to its default value. 1292 * That might be the value specified in the schema or the one set by the 1293 * administrator. 1294 * 1295 * Params: 1296 * key = the name of a key 1297 */ 1298 public void reset(string key) 1299 { 1300 g_settings_reset(gSettings, Str.toStringz(key)); 1301 } 1302 1303 /** 1304 * Reverts all non-applied changes to the settings. This function 1305 * does nothing unless @settings is in 'delay-apply' mode; see 1306 * g_settings_delay(). In the normal case settings are always applied 1307 * immediately. 1308 * 1309 * Change notifications will be emitted for affected keys. 1310 */ 1311 public void revert() 1312 { 1313 g_settings_revert(gSettings); 1314 } 1315 1316 /** 1317 * Sets @key in @settings to @value. 1318 * 1319 * A convenience variant of g_settings_set() for booleans. 1320 * 1321 * It is a programmer error to give a @key that isn't specified as 1322 * having a boolean type in the schema for @settings. 1323 * 1324 * Params: 1325 * key = the name of the key to set 1326 * value = the value to set it to 1327 * 1328 * Returns: %TRUE if setting the key succeeded, 1329 * %FALSE if the key was not writable 1330 * 1331 * Since: 2.26 1332 */ 1333 public bool setBoolean(string key, bool value) 1334 { 1335 return g_settings_set_boolean(gSettings, Str.toStringz(key), value) != 0; 1336 } 1337 1338 /** 1339 * Sets @key in @settings to @value. 1340 * 1341 * A convenience variant of g_settings_set() for doubles. 1342 * 1343 * It is a programmer error to give a @key that isn't specified as 1344 * having a 'double' type in the schema for @settings. 1345 * 1346 * Params: 1347 * key = the name of the key to set 1348 * value = the value to set it to 1349 * 1350 * Returns: %TRUE if setting the key succeeded, 1351 * %FALSE if the key was not writable 1352 * 1353 * Since: 2.26 1354 */ 1355 public bool setDouble(string key, double value) 1356 { 1357 return g_settings_set_double(gSettings, Str.toStringz(key), value) != 0; 1358 } 1359 1360 /** 1361 * Looks up the enumerated type nick for @value and writes it to @key, 1362 * within @settings. 1363 * 1364 * It is a programmer error to give a @key that isn't contained in the 1365 * schema for @settings or is not marked as an enumerated type, or for 1366 * @value not to be a valid value for the named type. 1367 * 1368 * After performing the write, accessing @key directly with 1369 * g_settings_get_string() will return the 'nick' associated with 1370 * @value. 1371 * 1372 * Params: 1373 * key = a key, within @settings 1374 * value = an enumerated value 1375 * 1376 * Returns: %TRUE, if the set succeeds 1377 */ 1378 public bool setEnum(string key, int value) 1379 { 1380 return g_settings_set_enum(gSettings, Str.toStringz(key), value) != 0; 1381 } 1382 1383 /** 1384 * Looks up the flags type nicks for the bits specified by @value, puts 1385 * them in an array of strings and writes the array to @key, within 1386 * @settings. 1387 * 1388 * It is a programmer error to give a @key that isn't contained in the 1389 * schema for @settings or is not marked as a flags type, or for @value 1390 * to contain any bits that are not value for the named type. 1391 * 1392 * After performing the write, accessing @key directly with 1393 * g_settings_get_strv() will return an array of 'nicks'; one for each 1394 * bit in @value. 1395 * 1396 * Params: 1397 * key = a key, within @settings 1398 * value = a flags value 1399 * 1400 * Returns: %TRUE, if the set succeeds 1401 */ 1402 public bool setFlags(string key, uint value) 1403 { 1404 return g_settings_set_flags(gSettings, Str.toStringz(key), value) != 0; 1405 } 1406 1407 /** 1408 * Sets @key in @settings to @value. 1409 * 1410 * A convenience variant of g_settings_set() for 32-bit integers. 1411 * 1412 * It is a programmer error to give a @key that isn't specified as 1413 * having a int32 type in the schema for @settings. 1414 * 1415 * Params: 1416 * key = the name of the key to set 1417 * value = the value to set it to 1418 * 1419 * Returns: %TRUE if setting the key succeeded, 1420 * %FALSE if the key was not writable 1421 * 1422 * Since: 2.26 1423 */ 1424 public bool setInt(string key, int value) 1425 { 1426 return g_settings_set_int(gSettings, Str.toStringz(key), value) != 0; 1427 } 1428 1429 /** 1430 * Sets @key in @settings to @value. 1431 * 1432 * A convenience variant of g_settings_set() for 64-bit integers. 1433 * 1434 * It is a programmer error to give a @key that isn't specified as 1435 * having a int64 type in the schema for @settings. 1436 * 1437 * Params: 1438 * key = the name of the key to set 1439 * value = the value to set it to 1440 * 1441 * Returns: %TRUE if setting the key succeeded, 1442 * %FALSE if the key was not writable 1443 * 1444 * Since: 2.50 1445 */ 1446 public bool setInt64(string key, long value) 1447 { 1448 return g_settings_set_int64(gSettings, Str.toStringz(key), value) != 0; 1449 } 1450 1451 /** 1452 * Sets @key in @settings to @value. 1453 * 1454 * A convenience variant of g_settings_set() for strings. 1455 * 1456 * It is a programmer error to give a @key that isn't specified as 1457 * having a string type in the schema for @settings. 1458 * 1459 * Params: 1460 * key = the name of the key to set 1461 * value = the value to set it to 1462 * 1463 * Returns: %TRUE if setting the key succeeded, 1464 * %FALSE if the key was not writable 1465 * 1466 * Since: 2.26 1467 */ 1468 public bool setString(string key, string value) 1469 { 1470 return g_settings_set_string(gSettings, Str.toStringz(key), Str.toStringz(value)) != 0; 1471 } 1472 1473 /** 1474 * Sets @key in @settings to @value. 1475 * 1476 * A convenience variant of g_settings_set() for string arrays. If 1477 * @value is %NULL, then @key is set to be the empty array. 1478 * 1479 * It is a programmer error to give a @key that isn't specified as 1480 * having an array of strings type in the schema for @settings. 1481 * 1482 * Params: 1483 * key = the name of the key to set 1484 * value = the value to set it to, or %NULL 1485 * 1486 * Returns: %TRUE if setting the key succeeded, 1487 * %FALSE if the key was not writable 1488 * 1489 * Since: 2.26 1490 */ 1491 public bool setStrv(string key, string[] value) 1492 { 1493 return g_settings_set_strv(gSettings, Str.toStringz(key), Str.toStringzArray(value)) != 0; 1494 } 1495 1496 /** 1497 * Sets @key in @settings to @value. 1498 * 1499 * A convenience variant of g_settings_set() for 32-bit unsigned 1500 * integers. 1501 * 1502 * It is a programmer error to give a @key that isn't specified as 1503 * having a uint32 type in the schema for @settings. 1504 * 1505 * Params: 1506 * key = the name of the key to set 1507 * value = the value to set it to 1508 * 1509 * Returns: %TRUE if setting the key succeeded, 1510 * %FALSE if the key was not writable 1511 * 1512 * Since: 2.30 1513 */ 1514 public bool setUint(string key, uint value) 1515 { 1516 return g_settings_set_uint(gSettings, Str.toStringz(key), value) != 0; 1517 } 1518 1519 /** 1520 * Sets @key in @settings to @value. 1521 * 1522 * A convenience variant of g_settings_set() for 64-bit unsigned 1523 * integers. 1524 * 1525 * It is a programmer error to give a @key that isn't specified as 1526 * having a uint64 type in the schema for @settings. 1527 * 1528 * Params: 1529 * key = the name of the key to set 1530 * value = the value to set it to 1531 * 1532 * Returns: %TRUE if setting the key succeeded, 1533 * %FALSE if the key was not writable 1534 * 1535 * Since: 2.50 1536 */ 1537 public bool setUint64(string key, ulong value) 1538 { 1539 return g_settings_set_uint64(gSettings, Str.toStringz(key), value) != 0; 1540 } 1541 1542 /** 1543 * Sets @key in @settings to @value. 1544 * 1545 * It is a programmer error to give a @key that isn't contained in the 1546 * schema for @settings or for @value to have the incorrect type, per 1547 * the schema. 1548 * 1549 * If @value is floating then this function consumes the reference. 1550 * 1551 * Params: 1552 * key = the name of the key to set 1553 * value = a #GVariant of the correct type 1554 * 1555 * Returns: %TRUE if setting the key succeeded, 1556 * %FALSE if the key was not writable 1557 * 1558 * Since: 2.26 1559 */ 1560 public bool setValue(string key, Variant value) 1561 { 1562 return g_settings_set_value(gSettings, Str.toStringz(key), (value is null) ? null : value.getVariantStruct()) != 0; 1563 } 1564 1565 /** 1566 * The "change-event" signal is emitted once per change event that 1567 * affects this settings object. You should connect to this signal 1568 * only if you are interested in viewing groups of changes before they 1569 * are split out into multiple emissions of the "changed" signal. 1570 * For most use cases it is more appropriate to use the "changed" signal. 1571 * 1572 * In the event that the change event applies to one or more specified 1573 * keys, @keys will be an array of #GQuark of length @n_keys. In the 1574 * event that the change event applies to the #GSettings object as a 1575 * whole (ie: potentially every key has been changed) then @keys will 1576 * be %NULL and @n_keys will be 0. 1577 * 1578 * The default handler for this signal invokes the "changed" signal 1579 * for each affected key. If any other connected handler returns 1580 * %TRUE then this default functionality will be suppressed. 1581 * 1582 * Params: 1583 * keys = an array of #GQuarks for the changed keys, or %NULL 1584 * nKeys = the length of the @keys array, or 0 1585 * 1586 * Returns: %TRUE to stop other handlers from being invoked for the 1587 * event. FALSE to propagate the event further. 1588 */ 1589 gulong addOnChange(bool delegate(void*, int, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1590 { 1591 return Signals.connect(this, "change-event", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1592 } 1593 1594 /** 1595 * The "changed" signal is emitted when a key has potentially changed. 1596 * You should call one of the g_settings_get() calls to check the new 1597 * value. 1598 * 1599 * This signal supports detailed connections. You can connect to the 1600 * detailed signal "changed::x" in order to only receive callbacks 1601 * when key "x" changes. 1602 * 1603 * Note that @settings only emits this signal if you have read @key at 1604 * least once while a signal handler was already connected for @key. 1605 * 1606 * Params: 1607 * key = the name of the key that changed 1608 */ 1609 gulong addOnChanged(void delegate(string, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1610 { 1611 return Signals.connect(this, "changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1612 } 1613 1614 /** 1615 * The "writable-change-event" signal is emitted once per writability 1616 * change event that affects this settings object. You should connect 1617 * to this signal if you are interested in viewing groups of changes 1618 * before they are split out into multiple emissions of the 1619 * "writable-changed" signal. For most use cases it is more 1620 * appropriate to use the "writable-changed" signal. 1621 * 1622 * In the event that the writability change applies only to a single 1623 * key, @key will be set to the #GQuark for that key. In the event 1624 * that the writability change affects the entire settings object, 1625 * @key will be 0. 1626 * 1627 * The default handler for this signal invokes the "writable-changed" 1628 * and "changed" signals for each affected key. This is done because 1629 * changes in writability might also imply changes in value (if for 1630 * example, a new mandatory setting is introduced). If any other 1631 * connected handler returns %TRUE then this default functionality 1632 * will be suppressed. 1633 * 1634 * Params: 1635 * key = the quark of the key, or 0 1636 * 1637 * Returns: %TRUE to stop other handlers from being invoked for the 1638 * event. FALSE to propagate the event further. 1639 */ 1640 gulong addOnWritableChange(bool delegate(uint, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1641 { 1642 return Signals.connect(this, "writable-change-event", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1643 } 1644 1645 /** 1646 * The "writable-changed" signal is emitted when the writability of a 1647 * key has potentially changed. You should call 1648 * g_settings_is_writable() in order to determine the new status. 1649 * 1650 * This signal supports detailed connections. You can connect to the 1651 * detailed signal "writable-changed::x" in order to only receive 1652 * callbacks when the writability of "x" changes. 1653 * 1654 * Params: 1655 * key = the key 1656 */ 1657 gulong addOnWritableChanged(void delegate(string, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1658 { 1659 return Signals.connect(this, "writable-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1660 } 1661 }